/*
 * This file is part of the Gwt-Generator project and was written by Henri Darmet for Objet Direct
 * <http://wwww.objetdirect.com>
 * 
 * Copyright © 2009 Objet Direct
 * 
 * Gwt-Generator is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later version.
 * 
 * Gwt-Generator is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along with Gwt-Generator. If not, see <http://www.gnu.org/licenses/>.
 */

package com.objetdirect.seam;

import junit.framework.TestCase;

import com.objetdirect.engine.ScriptDescriptor;
import com.objetdirect.engine.TestUtil;
import com.objetdirect.entities.EntityDescriptor;

public class TestTransientTabSetDescriptor extends TestCase {

	public void testSimpleTabSet() {	
		Seam.clear();
		EntityDescriptor agency = new EntityDescriptor("com.objetdirect.domain", "Agency").
			addStringField("name", null).
			addStringField("phone", null);
		PageDescriptor page = 
			new PageDescriptor("com.objetdirect.actions", "EditAgencies", "views", "edit-agencies");
		TransientTabSetDescriptor feature = new TransientTabSetDescriptor(agency, "#{lineEntity.name}");
		feature.addForm(new FormDescriptor().
			editStringField("name", "Nom de l'agence", 30).
			editStringField("phone", "Telephone", 10));
		page.setFeature(feature);
		page.build();
		TestUtil.assertText(page.getJavaText(),
			"package com.objetdirect.actions;",
			"",
			"import com.objetdirect.domain.Agency;",
			"import com.objetdirect.jsffrmk.GuiUtil;",
			"import java.util.List;",
			"import javax.faces.context.FacesContext;",
			"import javax.persistence.EntityManager;",
			"import org.jboss.seam.annotations.In;",
			"import org.jboss.seam.annotations.Name;",
			"import org.jboss.seam.annotations.Scope;",
			"import org.jboss.seam.core.Conversation;",
			"import org.jboss.seam.ScopeType;",
			"",
			"@Name(\"editAgencies\")",
			"@Scope(ScopeType.CONVERSATION)",
			"public class EditAgenciesAnimator {",
			"",
			"	@In",
			"	EntityManager entityManager;",
			"	static final int NAV_NONE = -1;",
			"	int navigationIndex = NAV_NONE;",
			"	List<Agency> agencies = null;",
			"	Agency currentAgency = null;",
			"	int currentAgencyIndex = -1;",
			"	String currentAgencyName;",
			"	String currentAgencyPhone;",
			"",
			"	public EditAgenciesAnimator() {",
			"		if (Conversation.instance().isLongRunning()) {",
			"			Conversation.instance().end(true);",
			"			Conversation.instance().leave();",
			"		}",
			"		Conversation.instance().begin();",
			"	}",
			"",
			"	public void setCurrentAgencyIndex(int currentAgencyIndex) {",
			"		if (isCurrentAgencyDirty()) {",
			"			navigationIndex = currentAgencyIndex;",
			"		}",
			"		else {",
			"			GuiUtil.invalidateSubmit();",
			"			changeCurrentAgencyIndex(currentAgencyIndex);",
			"		}",
			"	}",
			"	",
			"	@SuppressWarnings(\"unchecked\")",
			"	public List<Agency> getAgencies() {",
			"		if (agencies==null) {",
			"			agencies = entityManager.createQuery(\"from Agency\").getResultList();",
			"			if (agencies.size()==0) {",
			"				currentAgencyIndex=NAV_NONE;",
			"				currentAgency = null;",
			"			}",
			"			else",
			"				setCurrentAgencyIndex(0);",
			"		}",
			"		return agencies;",
			"	}",
			"	",
			"	public boolean isAgencyListVisible() {",
			"		return getAgencies().size()>0;",
			"	}",
			"	",
			"	public int getCurrentAgencyIndex() {",
			"		return currentAgencyIndex;",
			"	}",
			"	",
			"	public Agency getCurrentAgency() {",
			"		return currentAgency;",
			"	}",
			"	",
			"	void setCurrentAgency(Agency currentAgency) {",
			"		if (this.currentAgency != currentAgency) {",
			"			this.currentAgency = currentAgency;",
			"			currentAgencyName = currentAgency.getName();",
			"			currentAgencyPhone = currentAgency.getPhone();",
			"		}",
			"	}",
			"	",
			"	boolean isCurrentAgencyValid() {",
			"		return !FacesContext.getCurrentInstance().getMessages().hasNext();",
			"	}",
			"	",
			"	void changeCurrentAgencyIndex(int currentAgencyIndex) {",
			"		this.currentAgencyIndex = currentAgencyIndex;",
			"		if (this.currentAgencyIndex>=agencies.size())",
			"			this.currentAgencyIndex = agencies.size()-1;",
			"		if (this.currentAgencyIndex>=0)",
			"			setCurrentAgency(agencies.get(this.currentAgencyIndex));",
			"	}",
			"	",
			"	boolean isCurrentAgencyDirty() {",
			"		if (currentAgency==null)",
			"			return false;",
			"		if (!GuiUtil.equals(currentAgencyName, currentAgency.getName()))",
			"			return true;",
			"		if (!GuiUtil.equals(currentAgencyPhone, currentAgency.getPhone()))",
			"			return true;",
			"		return false;",
			"	}",
			"	",
			"	public boolean validateCurrentAgency() {",
			"		if (isCurrentAgencyValid()) {",
			"			currentAgency.setName(currentAgencyName);",
			"			currentAgency.setPhone(currentAgencyPhone);",
			"			return true;",
			"		}",
			"		else",
			"			return false;",
			"	}",
			"	",
			"	public boolean isConfirmNavigationRequested() {",
			"		return navigationIndex!=NAV_NONE;",
			"	}",
			"	",
			"	public void cancelNavigation() {",
			"		navigationIndex=NAV_NONE;",
			"	}",
			"	",
			"	void justNavigate() {",
			"		setCurrentAgencyIndex(navigationIndex);",
			"		navigationIndex = NAV_NONE;",
			"	}",
			"	",
			"	public void saveAndNavigate() {",
			"		if (validateCurrentAgency())",
			"			justNavigate();",
			"	}",
			"	",
			"	public void cancelCurrentAgency() {",
			"		GuiUtil.cancelGui();",
			"		changeCurrentAgencyIndex(currentAgencyIndex);",
			"	}",
			"	",
			"	public void navigate() {",
			"		cancelCurrentAgency();",
			"		justNavigate();",
			"	}",
			"	",
			"	public String getCurrentAgencyName() {",
			"		return currentAgencyName;",
			"	}",
			"	",
			"	public void setCurrentAgencyName(String currentAgencyName) {",
			"		if (GuiUtil.isSubmitValid())",
			"			this.currentAgencyName = currentAgencyName;",
			"	}",
			"	",
			"	public String getCurrentAgencyPhone() {",
			"		return currentAgencyPhone;",
			"	}",
			"	",
			"	public void setCurrentAgencyPhone(String currentAgencyPhone) {",
			"		if (GuiUtil.isSubmitValid())",
			"			this.currentAgencyPhone = currentAgencyPhone;",
			"	}",
			"",
			"}"
		);
		TestUtil.assertText(page.getFaceletText(),
			"<!DOCTYPE composition PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"",
			"			\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">",
			"<ui:composition xmlns=\"http://www.w3.org/1999/xhtml\"",
			"	xmlns:s=\"http://jboss.com/products/seam/taglib\"",
			"	xmlns:ui=\"http://java.sun.com/jsf/facelets\"",
			"	xmlns:f=\"http://java.sun.com/jsf/core\"",
			"	xmlns:h=\"http://java.sun.com/jsf/html\"",
			"	xmlns:ice=\"http://www.icesoft.com/icefaces/component\"",
			"	template=\"/layout/template.xhtml\">",
			"",
			"<ui:define name=\"body\">",
			"",
			"	<h:messages styleClass=\"message\"/>",
			"",
			"	<ice:form id=\"pageForm\">",
			"		<ice:panelGroup	styleClass=\"formBorderHighlight\">",
			"",
			"			<div class=\"dialog\">",
			"				<h:panelGroup>",
			"					<ice:panelTabSet var=\"agency\" value=\"#{editAgencies.agencies}\" selectedIndex=\"#{editAgencies.currentAgencyIndex}\"",
			"						tabPlacement=\"top\" rendered=\"#{editAgencies.agencyListVisible}\">",
			"						<ice:panelTab label=\"#{agency.name}\" >",
			"							<s:validateAll>",
			"								<h:panelGrid columns=\"4\" rowClasses=\"prop\" columnClasses=\"name,value,name,value\">",
			"									<h:outputText value=\"Nom de l'agence : \" />",
			"									<s:decorate template=\"/layout/edit.xhtml\">",
			"										<h:inputText value=\"#{editAgencies.currentAgencyName}\" size=\"30\"/>",
			"									</s:decorate>",
			"									<h:outputText value=\"Telephone : \" />",
			"									<s:decorate template=\"/layout/edit.xhtml\">",
			"										<h:inputText value=\"#{editAgencies.currentAgencyPhone}\" size=\"10\"/>",
			"									</s:decorate>",
			"								</h:panelGrid>",
			"							</s:validateAll>",
			"						</ice:panelTab>",
			"					</ice:panelTabSet>",
			"					<h:panelGroup>",
			"						<h:commandButton value=\"Valider\" action=\"#{editAgencies.validateCurrentAgency}\" rendered=\"#{editAgencies.agencyListVisible}\"/>",
			"						<h:commandButton value=\"Annuler\" immediate=\"true\" action=\"#{editAgencies.cancelCurrentAgency}\" rendered=\"#{editAgencies.agencyListVisible}\"/>",
			"					</h:panelGroup>",
			"				</h:panelGroup>",
			"			</div>",
			"		</ice:panelGroup>",
			"		<ice:panelPopup modal=\"true\" draggable=\"true\" styleClass=\"popup\" rendered=\"#{editAgencies.confirmNavigationRequested}\">",
			"			<f:facet name=\"header\">",
			"				<ice:panelGrid styleClass=\"title\" cellpadding=\"0\" cellspacing=\"0\" columns=\"2\">",
			"					<ice:outputText value=\"Confirmation\"/>",
			"				</ice:panelGrid>",
			"			</f:facet> ",
			"			<f:facet name=\"body\">",
			"				<ice:panelGrid width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" column=\"1\" styleClass=\"body\">",
			"					<ice:outputText value=\"Des donnees ont ete modifiees. Voulez vous continuer ?\" />",
			"					<div class=\"actionButtons\">",
			"						<h:commandButton value=\"continuer\" action=\"#{editAgencies.navigate}\"/>",
			"						<h:commandButton value=\"sauver\" action=\"#{editAgencies.saveAndNavigate}\"/>",
			"						<h:commandButton value=\"annuler\" immediate=\"true\" action=\"#{editAgencies.cancelNavigation}\"/>",
			"					</div>",
			"				</ice:panelGrid>",
			"			</f:facet>",
			"		</ice:panelPopup>",
			"	</ice:form>",
			"</ui:define>",
			"</ui:composition>"
		);
	}

	public void testAllFeaturesTabSet() {	
		Seam.clear();
		EntityDescriptor agency = new EntityDescriptor("com.objetdirect.domain", "Agency").
			addStringField("name", null).
			addStringField("phone", null);
		PageDescriptor page = 
			new PageDescriptor("com.objetdirect.actions", "EditAgencies", "views", "edit-agencies");
		TransientTabSetDescriptor feature = new TransientTabSetDescriptor(agency, "#{lineEntity.name}");
		feature.addForm(new FormDescriptor().
			editStringField("name", "Nom de l'agence", 30).
			editStringField("phone", "Telephone", 10));
		feature.addCreate(
			new ScriptDescriptor(
				"return new Agency(\"Nom de l'agence\");"
			).replace("Agency", agency.getClassDescriptor())
		);
		feature.addDelete(
			"Voulez-vous supprimer l'agence : #{agencyToDelete.name} ?"
		);
		TransientCriteriaDescriptor criteria = new TransientCriteriaDescriptor().setForm(
			new FormDescriptor().
				editStringField("name", "Name", 20).
				editStringField("phone", "Phone", 10)
		);
		feature.setCriteria(criteria);	
		page.setFeature(feature);
		page.build();
		TestUtil.assertText(page.getJavaText(),
			"package com.objetdirect.actions;",
			"",
			"import com.objetdirect.domain.Agency;",
			"import com.objetdirect.jsffrmk.GuiUtil;",
			"import java.util.List;",
			"import javax.faces.context.FacesContext;",
			"import javax.persistence.EntityManager;",
			"import org.hibernate.criterion.Restrictions;",
			"import org.hibernate.Criteria;",
			"import org.hibernate.Session;",
			"import org.jboss.seam.annotations.In;",
			"import org.jboss.seam.annotations.Name;",
			"import org.jboss.seam.annotations.Scope;",
			"import org.jboss.seam.core.Conversation;",
			"import org.jboss.seam.ScopeType;",
			"",
			"@Name(\"editAgencies\")",
			"@Scope(ScopeType.CONVERSATION)",
			"public class EditAgenciesAnimator {",
			"",
			"	@In",
			"	EntityManager entityManager;",
			"	static final int NAV_NONE = -1;",
			"	static final int NAV_CREATE = -2;",
			"	static final int NAV_APPLY_CRITERIA = -3;",
			"	int navigationIndex = NAV_NONE;",
			"	List<Agency> agencies = null;",
			"	Agency currentAgency = null;",
			"	int currentAgencyIndex = -1;",
			"	boolean isNewAgency = false;",
			"	String agencyNameCriterion;",
			"	String agencyPhoneCriterion;",
			"	String currentAgencyName;",
			"	String currentAgencyPhone;",
			"	static final int OP_NONE = 0;",
			"	static final int OP_DELETE = 1;",
			"	int operation = OP_NONE;",
			"",
			"	public EditAgenciesAnimator() {",
			"		if (Conversation.instance().isLongRunning()) {",
			"			Conversation.instance().end(true);",
			"			Conversation.instance().leave();",
			"		}",
			"		Conversation.instance().begin();",
			"	}",
			"",
			"	public void setCurrentAgencyIndex(int currentAgencyIndex) {",
			"		if (isCurrentAgencyDirty()) {",
			"			navigationIndex = currentAgencyIndex;",
			"		}",
			"		else {",
			"			GuiUtil.invalidateSubmit();",
			"			changeCurrentAgencyIndex(currentAgencyIndex);",
			"		}",
			"	}",
			"	",
			"	@SuppressWarnings(\"unchecked\")",
			"	public List<Agency> getAgencies() {",
			"		if (agencies==null) {",
			"			agencies = getAgenciesCriteria().list();",
			"			if (agencies.size()==0) {",
			"				currentAgencyIndex=NAV_NONE;",
			"				currentAgency = null;",
			"			}",
			"			else",
			"				setCurrentAgencyIndex(0);",
			"		}",
			"		return agencies;",
			"	}",
			"	",
			"	public boolean isAgencyListVisible() {",
			"		return getAgencies().size()>0;",
			"	}",
			"	",
			"	public int getCurrentAgencyIndex() {",
			"		return currentAgencyIndex;",
			"	}",
			"	",
			"	public Agency getCurrentAgency() {",
			"		return currentAgency;",
			"	}",
			"	",
			"	void setCurrentAgency(Agency currentAgency) {",
			"		if (this.currentAgency != currentAgency) {",
			"			this.currentAgency = currentAgency;",
			"			currentAgencyName = currentAgency.getName();",
			"			currentAgencyPhone = currentAgency.getPhone();",
			"		}",
			"	}",
			"	",
			"	boolean isCurrentAgencyValid() {",
			"		return !FacesContext.getCurrentInstance().getMessages().hasNext();",
			"	}",
			"	",
			"	void changeCurrentAgencyIndex(int currentAgencyIndex) {",
			"		this.currentAgencyIndex = currentAgencyIndex;",
			"		if (this.currentAgencyIndex>=agencies.size())",
			"			this.currentAgencyIndex = agencies.size()-1;",
			"		if (this.currentAgencyIndex>=0)",
			"			setCurrentAgency(agencies.get(this.currentAgencyIndex));",
			"	}",
			"	",
			"	boolean isCurrentAgencyDirty() {",
			"		if(isNewAgency)",
			"			return true;",
			"		if (currentAgency==null)",
			"			return false;",
			"		if (!GuiUtil.equals(currentAgencyName, currentAgency.getName()))",
			"			return true;",
			"		if (!GuiUtil.equals(currentAgencyPhone, currentAgency.getPhone()))",
			"			return true;",
			"		return false;",
			"	}",
			"	",
			"	protected Agency buildAgency() {",
			"		return new Agency(\"Nom de l'agence\");",
			"	}",
			"	",
			"	void doCreateAgency() {",
			"		Agency Agency = buildAgency();",
			"		if (currentAgencyIndex==agencies.size()-1) {",
			"			agencies.add(Agency);",
			"			currentAgencyIndex = agencies.size()-1;",
			"		}",
			"		else {",
			"			currentAgencyIndex++;",
			"			agencies.add(currentAgencyIndex, Agency);",
			"		}",
			"		setCurrentAgency(Agency);",
			"		isNewAgency = true;",
			"	}",
			"	",
			"	public void createAgency() {",
			"		if (isCurrentAgencyDirty())",
			"			navigationIndex = NAV_CREATE;",
			"		else",
			"			doCreateAgency();",
			"	}",
			"	",
			"	public boolean validateCurrentAgency() {",
			"		if (isCurrentAgencyValid()) {",
			"			currentAgency.setName(currentAgencyName);",
			"			currentAgency.setPhone(currentAgencyPhone);",
			"			if (isNewAgency) {",
			"				entityManager.persist(currentAgency);",
			"				isNewAgency = false;",
			"			}",
			"			return true;",
			"		}",
			"		else",
			"			return false;",
			"	}",
			"	",
			"	void deleteCurrentAgency() {",
			"		if (!isNewAgency)",
			"			entityManager.remove(currentAgency);",
			"		else",
			"			isNewAgency = false;",
			"		agencies.remove(currentAgency);",
			"		changeCurrentAgencyIndex(currentAgencyIndex);",
			"	}",
			"	",
			"	public void requestCurrentAgencyDeletion() {",
			"		operation = OP_DELETE;",
			"	}",
			"	",
			"	public boolean isConfirmNavigationRequested() {",
			"		return navigationIndex!=NAV_NONE;",
			"	}",
			"	",
			"	public void cancelNavigation() {",
			"		navigationIndex=NAV_NONE;",
			"	}",
			"	",
			"	public String getAgencyNameCriterion() {",
			"		return agencyNameCriterion;",
			"	}",
			"	",
			"	public void setAgencyNameCriterion(String agencyNameCriterion) {",
			"		this.agencyNameCriterion = agencyNameCriterion;",
			"	}",
			"	",
			"	public String getAgencyPhoneCriterion() {",
			"		return agencyPhoneCriterion;",
			"	}",
			"	",
			"	public void setAgencyPhoneCriterion(String agencyPhoneCriterion) {",
			"		this.agencyPhoneCriterion = agencyPhoneCriterion;",
			"	}",
			"	",
			"	public void validateAgenciesCriteria() {",
			"		if (isCurrentAgencyDirty())",
			"			navigationIndex = NAV_APPLY_CRITERIA;",
			"		else",
			"			doValidateCriteria();",
			"	}",
			"	",
			"	public void clearAgenciesCriteria() {",
			"		agencyNameCriterion = null;",
			"		agencyPhoneCriterion = null;",
			"	}",
			"	",
			"	Criteria getAgenciesCriteria() {",
			"		Session session = (Session)entityManager.getDelegate();",
			"		Criteria c = session.createCriteria(Agency.class);",
			"		if (agencyPhoneCriterion != null && agencyPhoneCriterion.length()>0)",
			"			c.add(Restrictions.like(\"phone\", agencyPhoneCriterion+\"%\"));",
			"		if (agencyNameCriterion != null && agencyNameCriterion.length()>0)",
			"			c.add(Restrictions.like(\"name\", agencyNameCriterion+\"%\"));",
			"		return c;",
			"	}",
			"	",
			"	void doValidateCriteria() {",
			"		agencies = null;",
			"	}",
			"	",
			"	void justNavigate() {",
			"		if (navigationIndex==NAV_CREATE)",
			"			doCreateAgency();",
			"		if (navigationIndex==NAV_APPLY_CRITERIA)",
			"			doValidateCriteria();",
			"		else",
			"			setCurrentAgencyIndex(navigationIndex);",
			"		navigationIndex = NAV_NONE;",
			"	}",
			"	",
			"	public void saveAndNavigate() {",
			"		if (validateCurrentAgency())",
			"			justNavigate();",
			"	}",
			"	",
			"	public void cancelCurrentAgency() {",
			"		GuiUtil.cancelGui();",
			"		if (isNewAgency) {",
			"			agencies.remove(currentAgency);",
			"			isNewAgency = false;",
			"		}",
			"		changeCurrentAgencyIndex(currentAgencyIndex);",
			"	}",
			"	",
			"	public void navigate() {",
			"		cancelCurrentAgency();",
			"		justNavigate();",
			"	}",
			"	",
			"	public String getCurrentAgencyName() {",
			"		return currentAgencyName;",
			"	}",
			"	",
			"	public void setCurrentAgencyName(String currentAgencyName) {",
			"		if (GuiUtil.isSubmitValid())",
			"			this.currentAgencyName = currentAgencyName;",
			"	}",
			"	",
			"	public String getCurrentAgencyPhone() {",
			"		return currentAgencyPhone;",
			"	}",
			"	",
			"	public void setCurrentAgencyPhone(String currentAgencyPhone) {",
			"		if (GuiUtil.isSubmitValid())",
			"			this.currentAgencyPhone = currentAgencyPhone;",
			"	}",
			"	",
			"	public int getOperation() {",
			"		return operation;",
			"	}",
			"	",
			"	public void setOperation(int operation) {",
			"		this.operation = operation;",
			"	}",
			"	",
			"	public void cancelOperation() {",
			"		operation = OP_NONE;",
			"	}",
			"	",
			"	public void continueOperation() {",
			"		if (operation == OP_DELETE) {",
			"			deleteCurrentAgency();",
			"		}",
			"		operation = OP_NONE;",
			"	}",
			"	",
			"	public boolean isConfirmRequested() {",
			"		return operation != OP_NONE;",
			"	}",
			"	",
			"	public void setConfirmRequested(boolean confirmRequested) {",
			"		if (!confirmRequested) {",
			"			cancelOperation();",
			"		}",
			"	}",
			"",
			"}"
		);
		TestUtil.assertText(page.getFaceletText(),
			"<!DOCTYPE composition PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"",
			"			\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">",
			"<ui:composition xmlns=\"http://www.w3.org/1999/xhtml\"",
			"	xmlns:s=\"http://jboss.com/products/seam/taglib\"",
			"	xmlns:ui=\"http://java.sun.com/jsf/facelets\"",
			"	xmlns:f=\"http://java.sun.com/jsf/core\"",
			"	xmlns:h=\"http://java.sun.com/jsf/html\"",
			"	xmlns:ice=\"http://www.icesoft.com/icefaces/component\"",
			"	template=\"/layout/template.xhtml\">",
			"",
			"<ui:define name=\"body\">",
			"",
			"	<h:messages styleClass=\"message\"/>",
			"",
			"	<ice:form id=\"pageForm\">",
			"		<ice:panelGroup	styleClass=\"formBorderHighlight\">",
			"",
			"			<div class=\"dialog\">",
			"				<h:panelGroup>",
			"					<h:panelGroup>",
			"						<s:validateAll>",
			"							<h:panelGrid columns=\"4\" rowClasses=\"prop\" columnClasses=\"name,value,name,value\">",
			"								<h:outputText value=\"Name : \" />",
			"								<s:decorate template=\"/layout/edit.xhtml\">",
			"									<h:inputText value=\"#{editAgencies.agencyNameCriterion}\" size=\"20\"/>",
			"								</s:decorate>",
			"								<h:outputText value=\"Phone : \" />",
			"								<s:decorate template=\"/layout/edit.xhtml\">",
			"									<h:inputText value=\"#{editAgencies.agencyPhoneCriterion}\" size=\"10\"/>",
			"								</s:decorate>",
			"							</h:panelGrid>",
			"						</s:validateAll>",
			"						<div class=\"actionButtons\">",
			"							<h:commandButton value=\"valider\" action=\"#{editAgencies.validateAgenciesCriteria}\"/>",
			"							<h:commandButton value=\"reinitialiser\" action=\"#{editAgencies.clearAgenciesCriteria}\"/>",
			"						</div>",
			"					</h:panelGroup>",
			"					<ice:panelTabSet var=\"agency\" value=\"#{editAgencies.agencies}\" selectedIndex=\"#{editAgencies.currentAgencyIndex}\"",
			"						tabPlacement=\"top\" rendered=\"#{editAgencies.agencyListVisible}\">",
			"						<ice:panelTab label=\"#{agency.name}\" >",
			"							<s:validateAll>",
			"								<h:panelGrid columns=\"4\" rowClasses=\"prop\" columnClasses=\"name,value,name,value\">",
			"									<h:outputText value=\"Nom de l'agence : \" />",
			"									<s:decorate template=\"/layout/edit.xhtml\">",
			"										<h:inputText value=\"#{editAgencies.currentAgencyName}\" size=\"30\"/>",
			"									</s:decorate>",
			"									<h:outputText value=\"Telephone : \" />",
			"									<s:decorate template=\"/layout/edit.xhtml\">",
			"										<h:inputText value=\"#{editAgencies.currentAgencyPhone}\" size=\"10\"/>",
			"									</s:decorate>",
			"								</h:panelGrid>",
			"							</s:validateAll>",
			"						</ice:panelTab>",
			"					</ice:panelTabSet>",
			"					<h:panelGroup>",
			"						<h:commandButton value=\"Valider\" action=\"#{editAgencies.validateCurrentAgency}\" rendered=\"#{editAgencies.agencyListVisible}\"/>",
			"						<h:commandButton value=\"Annuler\" immediate=\"true\" action=\"#{editAgencies.cancelCurrentAgency}\" rendered=\"#{editAgencies.agencyListVisible}\"/>",
			"						<h:commandButton value=\"Creer\" action=\"#{editAgencies.createAgency}\"/>",
			"						<h:commandButton value=\"Supprimer\" action=\"#{editAgencies.requestCurrentAgencyDeletion}\" rendered=\"#{editAgencies.agencyListVisible}\"/>",
			"					</h:panelGroup>",
			"				</h:panelGroup>",
			"			</div>",
			"		</ice:panelGroup>",
			"		<ice:panelPopup modal=\"true\" draggable=\"true\" styleClass=\"popup\" rendered=\"#{editAgencies.confirmRequested}\">",
			"			<f:facet name=\"header\">",
			"				<ice:panelGrid styleClass=\"title\" cellpadding=\"0\" cellspacing=\"0\" columns=\"2\">",
			"					<ice:outputText value=\"Confirmation\"/>",
			"				</ice:panelGrid>",
			"			</f:facet>",
			"			<f:facet name=\"body\">",
			"				<ice:panelGrid width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" column=\"1\" styleClass=\"body\">",
			"					<ice:outputText value=\"Voulez-vous supprimer l'agence : #{editAgencies.currentAgency.name} ?\" rendered=\"#{editAgencies.operation==1}\"/>",
			"					<div class=\"actionButtons\">",
			"						<h:commandButton value=\"valider\" action=\"#{editAgencies.continueOperation}\"/>",
			"						<h:commandButton value=\"annuler\" immediate=\"true\" action=\"#{editAgencies.cancelOperation}\"/>",
			"					</div>",
			"				</ice:panelGrid>",
			"			</f:facet>",
			"		</ice:panelPopup>",
			"		<ice:panelPopup modal=\"true\" draggable=\"true\" styleClass=\"popup\" rendered=\"#{editAgencies.confirmNavigationRequested}\">",
			"			<f:facet name=\"header\">",
			"				<ice:panelGrid styleClass=\"title\" cellpadding=\"0\" cellspacing=\"0\" columns=\"2\">",
			"					<ice:outputText value=\"Confirmation\"/>",
			"				</ice:panelGrid>",
			"			</f:facet> ",
			"			<f:facet name=\"body\">",
			"				<ice:panelGrid width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" column=\"1\" styleClass=\"body\">",
			"					<ice:outputText value=\"Des donnees ont ete modifiees. Voulez vous continuer ?\" />",
			"					<div class=\"actionButtons\">",
			"						<h:commandButton value=\"continuer\" action=\"#{editAgencies.navigate}\"/>",
			"						<h:commandButton value=\"sauver\" action=\"#{editAgencies.saveAndNavigate}\"/>",
			"						<h:commandButton value=\"annuler\" immediate=\"true\" action=\"#{editAgencies.cancelNavigation}\"/>",
			"					</div>",
			"				</ice:panelGrid>",
			"			</f:facet>",
			"		</ice:panelPopup>",
			"	</ice:form>",
			"</ui:define>",
			"</ui:composition>"
		);
	}
}